<template>
  <view class="invitationRewards">
    <topTitle :title="$t('invitationRewards.title')" />
    <view class="title">{{ $t('invitationRewards.description') }}</view>
    <view class="list" v-if="listData.length">
      <view>
        <view>{{ $t('invitationRewards.list.account') }}</view>
        <view>{{ $t('invitationRewards.list.recordTime') }}</view>
        <view>{{ $t('invitationRewards.list.income') }}</view>
      </view>
      <view v-for="(item, idx) in listData" :key="idx">
        <view>{{ item.trigger_user_name }}</view>
        <view>{{ formattingTime(item.add_time) }}</view>
        <view>{{ item.money }}</view>
      </view>
    </view>
    <noData v-else />
  </view>
</template>

<script setup lang="ts">
import { ref, getCurrentInstance } from "vue";
import { onReachBottom } from "@dcloudio/uni-app";

const instance = getCurrentInstance()?.appContext.config.globalProperties;
import { TeamRebateOrder } from "@/api/UserApi";





let listData = ref<Array<any>>([]);
let select_time: any = null;
const initFn = async () => {
	let list = await TeamRebateOrder({select_time})

	if (!select_time) {
		listData.value = list;
	} else {
		listData.value = [...listData.value, ...list];
	}
};

initFn()

onReachBottom(() => {
	select_time = listData.value[listData.value.length - 1].add_time;
	initFn();
});

</script>
<style scoped lang="scss">
@import "../../static/scss/invite.scss";
</style>